/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package edu.pku.sei.ocl.cst.impl;

import edu.pku.sei.ocl.cst.CSTPackage;
import edu.pku.sei.ocl.cst.ReflectiveVariableCS;
import edu.pku.sei.ocl.cst.VariableExpCS;
import edu.pku.sei.ocl.evaluation.Context;
import edu.pku.sei.ocl.visitor.AbstractOCLVisitor;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Reflective Variable CS</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link edu.pku.sei.ocl.cst.impl.ReflectiveVariableCSImpl#getReflectiveType <em>Reflective Type</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ReflectiveVariableCSImpl extends VariableCSImpl implements
		ReflectiveVariableCS {
	/**
	 * The cached value of the '{@link #getReflectiveType() <em>Reflective Type</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getReflectiveType()
	 * @generated
	 * @ordered
	 */
	protected VariableExpCS reflectiveType;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ReflectiveVariableCSImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return CSTPackage.Literals.REFLECTIVE_VARIABLE_CS;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public VariableExpCS getReflectiveType() {
		return reflectiveType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetReflectiveType(
			VariableExpCS newReflectiveType, NotificationChain msgs) {
		VariableExpCS oldReflectiveType = reflectiveType;
		reflectiveType = newReflectiveType;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this,
					Notification.SET,
					CSTPackage.REFLECTIVE_VARIABLE_CS__REFLECTIVE_TYPE,
					oldReflectiveType, newReflectiveType);
			if (msgs == null)
				msgs = notification;
			else
				msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setReflectiveType(VariableExpCS newReflectiveType) {
		if (newReflectiveType != reflectiveType) {
			NotificationChain msgs = null;
			if (reflectiveType != null)
				msgs = ((InternalEObject) reflectiveType)
						.eInverseRemove(
								this,
								EOPPOSITE_FEATURE_BASE
										- CSTPackage.REFLECTIVE_VARIABLE_CS__REFLECTIVE_TYPE,
								null, msgs);
			if (newReflectiveType != null)
				msgs = ((InternalEObject) newReflectiveType)
						.eInverseAdd(
								this,
								EOPPOSITE_FEATURE_BASE
										- CSTPackage.REFLECTIVE_VARIABLE_CS__REFLECTIVE_TYPE,
								null, msgs);
			msgs = basicSetReflectiveType(newReflectiveType, msgs);
			if (msgs != null)
				msgs.dispatch();
		} else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					CSTPackage.REFLECTIVE_VARIABLE_CS__REFLECTIVE_TYPE,
					newReflectiveType, newReflectiveType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd,
			int featureID, NotificationChain msgs) {
		switch (featureID) {
		case CSTPackage.REFLECTIVE_VARIABLE_CS__REFLECTIVE_TYPE:
			return basicSetReflectiveType(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
		case CSTPackage.REFLECTIVE_VARIABLE_CS__REFLECTIVE_TYPE:
			return getReflectiveType();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case CSTPackage.REFLECTIVE_VARIABLE_CS__REFLECTIVE_TYPE:
			setReflectiveType((VariableExpCS) newValue);
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
		case CSTPackage.REFLECTIVE_VARIABLE_CS__REFLECTIVE_TYPE:
			setReflectiveType((VariableExpCS) null);
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
		case CSTPackage.REFLECTIVE_VARIABLE_CS__REFLECTIVE_TYPE:
			return reflectiveType != null;
		}
		return super.eIsSet(featureID);
	}

	@Override
	public Object accept(AbstractOCLVisitor visitor, Context c,
			Object... expectedResults) {
		if (expectedResults.length == 0) {
			return visitor.visitReflectiveVariableCS(this, c);
		} else {
			return visitor.visitReflectiveVariableCS(this, c, expectedResults);
		}
	}
} //ReflectiveVariableCSImpl
